<?php
/**************************************************
 *  Created:  2010-06-08
 *
 *  微博广场
 *
 *  @Xweibo (C)1996-2099 SINA Inc.
 *  @Author zhenquan <zhenquan@staff.sina.com.cn>
 *
 ***************************************************/
class adddiscount_mod
{
	/// 获取绑定信息
	function default_action() {

		//add by gt
		//获取当前用户的粉丝列表id
		$fids = DR('xweibo/xwb.getFriendIds', '', USER::uid(), null, null, -1, 5000);
		$fids = $fids['rst']['ids'];
		// add by gt end

		$followId = DS('common/sysConfig.get','', 'guide_auto_follow_id');
		$result = DR('mgr/userRecommendCom.getUserById', '', $followId);

		$rst = '';
		$weiboStr = '';
		if ($result['errno'] == 0) {
			$rst = &$result['rst'];


			if (!empty($rst)) {
				$ids = array();
				foreach ($rst as $row) {
					foreach ($fids as $fid){
						
						if($fid == $row['rel_uid']){
							$isExist = false;
							foreach ($fids as $fid1){
								if($fid1 == $row['uid']){
									$isExist = true;
									break;
								}
							}
							if(!$isExist){
								array_push($ids, $row['uid']);
								$weiboStr = $weiboStr.$row['nickname'].'<br>';	
							}
						}
					}
				}
				// mod by gt end-------
				$result = DR('xweibo/xwb.createFriendshipBatch', '', $ids);

				//清除缓存
				DD('xweibo/xwb.getFollowerIds');
				DD('xweibo/xwb.getFollowers');

			}

		}
		if (empty($weiboStr)) {
			$weiboStr = '<h3>没有任何可以添加的微博</h3><br>';
		}else{			
			$weiboStr = '<h3>成功添加以下微博</h3><br>'.$weiboStr;	
		}
		TPL::assign('weiboStr', $weiboStr);
		TPL::assign('data', $rst);

		TPL::display('showmsg');
	}


}
?>